﻿using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using CCF20Model;
using System.Collections;
using WiseLinkWPF.Windows.Controls;
using WiseLink.RDS.Resource;
using System.Collections.Generic;

namespace CCF20Module
{
    /// <summary>
    /// Interaction logic for DeviceSale.xaml
    /// </summary>
    public partial class Customer
    {
        
        private CollectionViewSource VehicleTypeLookupView;
        private CustomerViewModel customerViewModel;
        public Customer()
        {
            
            InitializeComponent();
            customerViewModel =new CustomerViewModel();
            this.DataContext = customerViewModel;
            customerViewModel.NewCustomerCreated = 
                        () =>
                        {
                            radGridView1.Items.MoveToLastPage();
                            radGridView1.Items.MoveCurrentToLast();
                            radGridView1.SelectedItem = radGridView1.CurrentItem;
                        };

        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

            VehicleTypeLookupView = (CollectionViewSource)this.FindResource("VehicleTypeLookup");
            customerModel.GetMyVehicleTypes();
            VehicleTypeLookupView.Source = customerModel.MyVehicleTypes;
            ApplyResourceToGrid();
            ApplyResourceToButton();
            ApplyResourceToCLRObjectBoundTextBox();
            ApplyResourceToLable();
            
            
        }

        private void radGridView1_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            //if (e.AddedItems.FirstOrDefault() != null)
            //{
            //    this.radGridView1.CurrentItem = e.AddedItems.First();
            //}
        }

        
    }
}
